﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Net.Mail;

public partial class Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void StepNextButton_Click(object sender, EventArgs e)
    {
        MembershipUser User;
        try
        {
            User = Membership.CreateUser(Email.Text, Password.Text, Email.Text);
        }
        catch (MembershipCreateUserException ex)
        {
            //ScriptManager.RegisterStartupScript(Master.FindControl("UpdatePanel1"), this.GetType(), "AddNewsOk", "alert('添加失败，错误原因为：" + ex.StatusCode.ToString() + "');", true);
            ErrorMessage.Text = "Register Fail:"+ex.StatusCode.ToString();
            return;
        }
        PersonInfoData person = new PersonInfoData();
        person.email = Email.Text;
        person.Title = DropDownList1.Text;
        person.FirstName = FirstName.Text;
        person.LastName = LastName.Text;
        person.Organization = Organization.Text;
        person.Department = Department.Text;
        person.Country = DropDownList2.Text;
        person.Address = Address.Text;
        PersonInfoDataDBOption.Insert(person);        
        //Membership.ValidateUser(Email.Text, Password.Text);
        FormsAuthentication.SetAuthCookie(Email.Text, true);
        Response.Redirect("~/Index.aspx");
    }
}